﻿// NHibernate Helper class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Cfg;

namespace RMD.Modal
{
    public class NHHelper
    {
        static ISessionFactory factory;

        static NHHelper()
        {
            Configuration cfg = new Configuration();
            cfg.Configure();
            cfg.AddAssembly("RMD.Modal");
            //string driverClass = cfg.GetProperty("connection.driver_class");
            //System.Diagnostics.Debug.WriteLine(driverClass);
            //driverClass = cfg.GetProperty("dialect");
            //System.Diagnostics.Debug.WriteLine(driverClass);
            factory = cfg.BuildSessionFactory();
        }

        public static ISession GetNHSession()
        {
            return factory.OpenSession();
        }
    }
}
